using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.Actions
{
	[Category("Input")]
	public class GetInputAxis : ActionTask
	{
		public string xAxisName = "Horizontal";

		public string yAxisName;

		public string zAxisName = "Vertical";

		public BBFloat multiplier = new BBFloat
		{
			value = 1f
		};

		[BlackboardOnly]
		public BBVector saveAs;

		[BlackboardOnly]
		public BBFloat saveXAs;

		[BlackboardOnly]
		public BBFloat saveYAs;

		[BlackboardOnly]
		public BBFloat saveZAs;

		public bool forever;

		protected override void OnExecute()
		{
			Do();
		}

		protected override void OnUpdate()
		{
			Do();
		}

		private void Do()
		{
			float num = ((!string.IsNullOrEmpty(xAxisName)) ? Input.GetAxis(xAxisName) : 0f);
			float num2 = ((!string.IsNullOrEmpty(yAxisName)) ? Input.GetAxis(yAxisName) : 0f);
			float num3 = ((!string.IsNullOrEmpty(zAxisName)) ? Input.GetAxis(zAxisName) : 0f);
			saveXAs.value = num * multiplier.value;
			saveYAs.value = num2 * multiplier.value;
			saveZAs.value = num3 * multiplier.value;
			saveAs.value = new Vector3(num, num2, num3) * multiplier.value;
			if (!forever)
			{
				EndAction();
			}
		}
	}
}
